Skip to content

Conversation

@WeylonSantana
Copy link
Contributor

resolves #2491

  • refactor give exp editor
  • adding support for decreasing the player's level using the give exp command
  • added a new event common trigger
Intersect_Client_nSBWzaJB3i.mp4

public readonly LocalizedString Left = @"{00} has left {01}.";

[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public readonly LocalizedString LevelDown = @"You have leveled down! You are now level {00}!";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't super natural in english, it would be better to say You have lost a level! You are now level {00}!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also change the name of the string to LevelLost

else
{
var levelCount = 0;
while (Exp < 0 && Level - levelCount > 1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+ levelCount

Comment on lines 1417 to 1418
Exp += GetExperienceToNextLevel(Level - levelCount - 1);
levelCount++;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Swap these

First line should be --levelCount; this takes into account that - 1 implicitly

Second line should be Exp += GetExperienceToNextLevel(Level + levelCount);

}

PacketSender.SendExperience(this);
AddLevels(-levelCount);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AddLevels(levelCount);

With the negative counting there's no reason to flip the sign.

if (Exp < 0)
{
Exp = 0;
PacketSender.SendExperience(this);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be outside of the if so that the changed EXP is sent above level 1?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any exp for any other level is sent at the end of AddLevels()
I added this if because, when I went down a level and was at level 1, after AddLevels() was executed, the exp would become negative if I removed more than I had

So I added this if as "if after removing the player's levels, the exp remains negative, reset and send"
the exp will never be negative after AddLevels(), if when the function finishes its level is above 1
It only happened exclusively in this situation, because the exp is not reset when leveling down, and it does not reset when it is negative when the player is at level 1.

Name
);

if (ClassBase.TryGet(ClassId, out var classDescriptor) && classDescriptor?.Spells != default)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put ClassBase? classDescriptor = null; before if (levels > 0)

Here, change the if to if ((classDescriptor?.Id == ClassId || ClassBase.TryGet(ClassId, out classDescriptor)) && classDescriptor?.Spells != default)

Name
);

if (ClassBase.TryGet(ClassId, out var classDescriptor) && classDescriptor?.Spells != default)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, change the if to if ((classDescriptor?.Id == ClassId || ClassBase.TryGet(ClassId, out classDescriptor)) && classDescriptor?.Spells != default)

}

public void TakeExperience(long amount)
public void TakeExperience(long amount, bool enableLevelDown = false)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add , bool force = false as the final parameter

public void TakeExperience(long amount, bool enableLevelDown = false)
{
if (this is Player && Options.Instance.Map.DisableExpLossInArenaMaps && Map.ZoneType == MapZone.Arena)
if (Options.Instance.Map.DisableExpLossInArenaMaps && Map.ZoneType == MapZone.Arena)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change this to if (force || (Options.Instance.Map.DisableExpLossInArenaMaps && Map.ZoneType == MapZone.Arena))

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Events taking experience should not be stopped by map type

}
else if (quantity < 0)
{
player.TakeExperience(Math.Abs(quantity), command.EnableLevelDown);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add , force: true to the end of the args

@WeylonSantana WeylonSantana force-pushed the add-level-down-support branch from a189c03 to b9cd717 Compare January 23, 2025 16:42
@pandinocoder pandinocoder merged commit 62f36d4 into AscensionGameDev:main Jan 23, 2025
1 check passed
@pandinocoder pandinocoder deleted the add-level-down-support branch January 23, 2025 21:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Negative xp support.

2 participants